package br.edu.infnet.avaliacao.model;

import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "formacao_aluno", catalog = "avaliacao")
public class FormacaoAluno implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private FormacaoAlunoId id;
	private Formacao formacao;
	private Aluno aluno;
	private Date dataInicio;
	private Date dataConclusao;

	public FormacaoAluno() {
	}

	public FormacaoAluno(FormacaoAlunoId id, Formacao formacao, Aluno aluno) {
		this.id = id;
		this.formacao = formacao;
		this.aluno = aluno;
	}

	public FormacaoAluno(FormacaoAlunoId id, Formacao formacao, Aluno aluno,
			Date dataInicio, Date dataConclusao) {
		this.id = id;
		this.formacao = formacao;
		this.aluno = aluno;
		this.dataInicio = dataInicio;
		this.dataConclusao = dataConclusao;
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "formacaoId", column = @Column(name = "formacao_id", nullable = false)),
			@AttributeOverride(name = "alunoId", column = @Column(name = "aluno_id", nullable = false)) })
	public FormacaoAlunoId getId() {
		return this.id;
	}

	public void setId(FormacaoAlunoId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "formacao_id", nullable = false, insertable = false, updatable = false)
	public Formacao getFormacao() {
		return this.formacao;
	}

	public void setFormacao(Formacao formacao) {
		this.formacao = formacao;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "aluno_id", nullable = false, insertable = false, updatable = false)
	public Aluno getAluno() {
		return this.aluno;
	}

	public void setAluno(Aluno aluno) {
		this.aluno = aluno;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "data_inicio", length = 10)
	public Date getDataInicio() {
		return this.dataInicio;
	}

	public void setDataInicio(Date dataInicio) {
		this.dataInicio = dataInicio;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "data_conclusao", length = 10)
	public Date getDataConclusao() {
		return this.dataConclusao;
	}

	public void setDataConclusao(Date dataConclusao) {
		this.dataConclusao = dataConclusao;
	}

}
